//
//  LoginMbd.m
//  SuerLinkProject
//
//  Created by apple on 16/1/8.
//  Copyright © 2016年 SuerLink. All rights reserved.
//

#import "LoginMbd.h"
#import "Unit.h"


@implementation LoginMbd
{
    int angle;
}
-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self)
    {
        angle = 0;
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.3];
        
        
        _imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ScreenW/2-30, ScreenH/2-30, 60, 60)];
        _imageView.image = [UIImage imageNamed:@"图层-3"];
        [self addSubview:_imageView];
        
    }
    return self;
}
-(void)startAnimation
{
    [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"stopHomeAnimation"];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.05];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(endAnimation)];
    _imageView.transform = CGAffineTransformMakeRotation(angle * (M_PI / 180.0f));
    [UIView commitAnimations];
}

-(void)endAnimation
{
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"stopHomeAnimation"] integerValue] == 1) {
        return;
    }
    angle += 10;
    [self startAnimation];
}

- (void)stopAnimation
{
    [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"stopHomeAnimation"];
}


@end
